package libtool65.cmd;

public class Option {
	
	private boolean has_argument;
	private String argument;

	Option(boolean has_argument)
	{
		this.has_argument = has_argument;
		this.argument = null;
	}

	public boolean hasArgument() {
		return has_argument;
	}

	public void setArgument(String text) {
		if (has_argument)
			argument = text;
	}

	public int getAddress() {
		int address = -1;
		if (argument != null)
		{
			try {
				address = Integer.parseInt(argument);
			} catch (NumberFormatException e)
			{ }
		}
		return address;
	}

	public boolean isPresent() {
		return argument != null;
	}

	public String getText() {
		return argument;
	}

}
